
<template>
	<!-- 巡检详情 巡检问题 -->
	<view>
		<view class="flex-col line-tabs Pgroup_4">
			<view class="flex-col group_6">
				<view class="flex-col group_7">
					<view class="flex-col items-start section_3">
						<view class="group_8">
							<text class="text_11">{{detailedName}}</text>
							<text class="text_12">（{{num}}/{{inspectionNums}}次）</text>
						</view>
					</view>
					<view class="flex-col section_4">
						<view class="justify-between">
							<text class="text_13">巡检工序</text>
							<text class="text_14">{{processName}}</text>
						</view>
						<view class="justify-between group_10">
							<text class="text_15">巡检子工序</text>
							<text class="text_16">{{childProcessName}}</text>
						</view>
					</view>
					<view class="flex-row section_5">
						<image :src="$IMG_URL+'16557870830761957884.png'" class="image_3" />
						<text class="text_17">提示：</text>
						<text class="text_18">
							墙体改拆需要注意安全并且需要做好售后服务墙体改拆需要注意安全并且需要做好售后服务
						</text>
					</view>
					<!-- -->
					<view class="flex-col section_6" v-for="(item,p) in proarr" :key="p">
						<view class="justify-between group_11">
							<text class="text_19">问题类型：</text>
							<view class="flex-row">
								<picker @change="(e)=>{bindPickerChange(e,p)}" :value="item.inspectionIndex"
									:range="array">
									<view class="uni-input">
										<text class="text_20">{{array[item.inspectionIndex]}}</text>
										<image :src="$IMG_URL+'index/goright.png'" class="image_4" />
									</view>
								</picker>
								<!--  -->
							</view>
						</view>
						<text class="text_21" >请输入发布巡检情况：</text>
						<view class="flex-col items-start text-wrapper_4">
							<textarea v-model="item.issueContent" cols="20" rows="10"
								placeholder="请输入巡检内容…"></textarea>
						</view>
						<view class="view">
							<view class="flex-row group_14" style="">
								<!-- <shop-upload2 :maxCount="9" :fileList="item.issueMedia" @del="delectPic($event,p)"
									@success='success($event,p)'></shop-upload2> -->
									<shop-upload :maxCount="9" :fileList="item.issueMedia" @del="delectPic($event,p)"
										@success='success($event,p)'></shop-upload>
							</view>
						</view>
						<view class="flex-row group_17">
							<text class="text_23">是否需要用户回复确认2：</text>
							<view class="flex-row">
								<radio-group @change="(e)=>{radioChange(e,p)}" class="flex-row">
									<label class="flex-row " v-for="(it, index) in radioList" :key="index"
										style="margin: 0 20rpx;transform:scale(0.8)">
										<view>
											<radio :value="String(it.value)"
												:checked="item.isUserReplyFlag === it.value" />
										</view>
										<view style="">{{it.name}}</view>
									</label>
								</radio-group>
							</view>
						</view>
					</view>
				</view>
				<view class="justify-center section_7" @click="addlist">
					<image :src="$IMG_URL+'16557868010275878721.png'" class="image_13" />
					<text class="text_26">巡检待解决</text>
				</view>
				<view class="flex-row group_19">
					<view class="flex-col items-center text-wrapper_5" @click="nextClick(0)"><text
							class="text_27">上一步</text></view>
					<view class="flex-col items-center text-wrapper_6" @click="nextClick(1)"><text
							class="text_28">下一步</text></view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {

		data() {
			return {
				radioList: [{
					name: '是',
					value: 1,
					checked: true
				}, {
					name: '否',
					value: 0
				}],
				current: 0,
				arrayindex: 0,
				array: [],
				fileList3: [],
				inspectionNums: '',
				num: '',
				childProcessName: '', //巡检子工序
				processName: '', //巡检工序
				issueContent: '', //巡检问题描述
				inspectionFrequencyId: '', //巡检次数ID
				arraylist: '',
				ordersId: '',
				fileList: [],
				detailedName: '',
				proarr: [{
					inspectionIndex: 0,
					inspectionId: 0,
					issueContent: '',
					issueMedia: [],
					isUserReplyFlag: 0,
					issueTypeId:''
				}],
				
			}
		},
		created() {
			this.ordersId = uni.getStorageSync('ordersId');
			this.getStorage();
			this.getDictCode();
			uni.startPullDownRefresh();
			setTimeout(function() {
				uni.stopPullDownRefresh();
			}, 1000);
			// console.log(this.ordersId)
		},
		
		
		
		methods: {
			addlist() {
				console.log(this.fileList3)
				this.proarr.push({
					inspectionIndex: 0,
					inspectionId: 0,
					issueContent: '',
					issueMedia: [],
					isUserReplyFlag: 0,
					issueTypeId:''
				})
			},
			Back() {
				uni.switchTab({
					url: '/pages/index/my',
					success: function() {
						beforePage.$vm.init();
					}
				})
			},
			delectPic(event, index) {
				// console.log(event);
				let item = this.proarr[index];
				item.issueMedia.splice(event, 1);

			},
			success(file, index) {
				let item = this.proarr[index];
				item.issueMedia.push({
					url: file.url
				})

				// console.log(this.fileList,'fileList');
			},
			getDictCode() {
				// 获取问题类型
				this.$http('common.getDictCode', {
					dictType: 'issue_type'
				}).then(res => {
					if (res.code == 200) {
						this.arraylist = res.data;
						for (var i = 0; i < res.data.length; i++) {
							this.array.push(res.data[i].dictLabel);
						}
					}
				})

			},
			getStorage() {
				const ordersId = uni.getStorageSync('ordersId');
				let inspectionFrequencyId = uni.getStorageSync('inspectionFrequencyId');
				this.$http('common.getInfolist', {
					ordersId: ordersId,
					type: '5',
					inspectionFrequencyId:inspectionFrequencyId
				}).then(res => {
					if (res.code == 200) {
						this.inspectionNums = res.data.inspectionNums;
						this.num = res.data.conductNum;
						this.processName = res.data.processName;
						this.childProcessName = res.data.childProcessName;
						this.inspectionFrequencyId = res.data.inspectionFrequencyId;
						this.detailedName = res.data.detailedName;

					}
				})
			},

			nextClick(e) {
				// console.log(this.proarr,'proarr')
				// 如果巡检次数是最后一次
				if (e == 0) {
					this.$emit('getState', '1')
				} else {
					
						// if (Number(this.num) == Number(this.inspectionNums)) {
						// 	uni.switchTab({
						// 		url: '/pages/index'
						// 	});
							let proarr = [];
							for (var i = 0; i < this.proarr.length; i++) {
								let newurl = []
								this.proarr[i].inspectionId = this.inspectionFrequencyId;
								let indexAA = this.proarr[i].inspectionIndex;
								this.proarr[i].issueTypeId = this.arraylist[indexAA].dictCode;
								for (var j = 0; j < this.proarr[i].issueMedia.length; j++) {
									newurl.push(this.proarr[i].issueMedia[j].url)
								}
								this.proarr[i].issueMedia = newurl.join(',');
								
							}
							console.log(this.proarr,'proarr')
							// this.$http('onsite.addPatrol', this.proarr).then(res => {
							// 	if (res.code == 200) {
							// 		this.$emit('getState', '2')
							// 	} else {
							// 		uni.showToast({
							// 			title: res.msg,
							// 			icon: "error"
							// 		})
							// 	}
							// })
							// return;
						}

						// let proarr = [];
						// console.log(this.proarr, 'this.proarr');
						// for (var i = 0; i < this.proarr.length; i++) {
						// 	let newurl = []
						// 	this.proarr[i].inspectionId = this.inspectionFrequencyId;
						// 	let indexAA = this.proarr[i].inspectionIndex;						// 	this.proarr[i].issueTypeId = this.arraylist[indexAA].dictCode;
						// 	for (var j = 0; j < this.proarr[i].issueMedia.length; j++) {
						// 		newurl.push(this.proarr[i].issueMedia[j].url)
						// 	}
						// 	this.proarr[i].issueMedia = newurl.join(',');
						// }
						
				// 		console.log(this.proarr,'this.proarr')
				// 		// 新增巡检问题
						// this.$http('onsite.addPatrol', this.proarr).then(res => {
						// 	if (res.code == 200) {
						// 		this.$emit('getState', '2')
						// 	} else {
						// 		uni.showToast({
						// 			title: res.msg,
						// 			icon: "error"
						// 		})
						// 	}
						// })
				}

				// console.log(111)
			},
			radioChange(e, index) {
				console.log(e);
				let item = this.proarr[index];
				item.isUserReplyFlag = e.detail.value;
				this.$set(this.proarr, index, item)
				// console.log(this.current);
			},
			bindPickerChange(e, index) {
				// this.array[index].date = e.detail.value;
				let item = this.proarr[index];
				
				item.inspectionIndex = e.detail.value;
				console.log(item.inspectionIndex)
				this.$set(this.proarr, index, item);
			},
		}
	}
</script>

<style scoped lang="scss">
	.u-upload {
		display: flex;
		flex-direction: initial;
	}

	/deep/.u-upload__wrap {
		flex-wrap: nowrap;
	}

	.image_2F {
		width: 214rpx;
		height: 214rpx;
	}

	.line-tabs {
		position: relative;
	}

	.image_5 {
		border-radius: 16rpx;
		width: 208rpx;
		height: 208rpx;
	}

	.image_8 {
		width: 72rpx;
		height: 72rpx;
	}

	.page {
		background-color: #f6f7f9ff;
		height: 100%;
		width: 100%;
		overflow-y: auto;
		overflow-x: hidden;
	}

	.section_1 {
		padding: 30.5rpx 21rpx 110rpx;
		background-image: url($IMG_URL+'16557870724016329987.png');
		background-position: 0% 0%;
		background-size: 100% 100%;
		background-repeat: no-repeat;
	}

	.group_4 {
		margin-top: -110rpx;
	}

	.group {
		padding: 24.5rpx 10.5rpx 28rpx;
		position: relative;
	}

	.section_2 {
		padding: 0 43rpx 84rpx;
		background-image: url($IMG_URL+'16557870830617903945.png');
		background-position: 0% 0%;
		background-size: 100% 100%;
		background-repeat: no-repeat;
	}

	.group_5 {
		padding: 12rpx 40rpx 42rpx;
		position: relative;
	}

	.group_6 {
		margin-top: 11rpx;
		padding: 0 23rpx;
	}

	.image {
		position: absolute;
		left: 10.5rpx;
		bottom: 24.5rpx;
		width: 21rpx;
		height: 36rpx;
	}

	.text {
		color: #333333;
		font-size: 36rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 43rpx;
	}

	.group_1 {
		padding: 47rpx 0 24rpx;
		border-bottom: solid 1rpx #ffffff3d;
	}

	.group_2 {
		margin-top: 21rpx;
	}

	.group_3 {
		margin-top: 24rpx;
	}

	.text-wrapper_1 {
		margin-top: 5rpx;
	}

	.text-wrapper_2 {
		margin-top: 5rpx;
	}

	.text-wrapper_3 {
		margin-top: 5rpx;
	}

	.image_2 {
		width: 40rpx;
		height: 16rpx;
		position: absolute;
		left: 84rpx;
		bottom: 12rpx;
	}

	.group_7 {
		padding-bottom: 32rpx;
	}

	.section_7 {
		margin-right: 9rpx;
		padding: 13rpx 0 21rpx;
		align-self: flex-end;
		border-radius: 32rpx;
		background-image: url($IMG_URL+'16557870846764303061.png');
		background-position: 0% 0%;
		background-size: 100% 100%;
		background-repeat: no-repeat;
		width: 220rpx;
	}

	.group_19 {
		padding: 56rpx 9rpx 48rpx;
	}

	.image_1 {
		border-radius: 50%;
		width: 96rpx;
		height: 96rpx;
	}

	.text_1 {
		margin-left: 32rpx;
		margin-top: 19rpx;
		color: #ffffff;
		font-size: 36rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 43rpx;
	}

	.text_2 {
		margin-top: 7rpx;
		color: #ffffff;
		font-size: 32rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 38rpx;
	}

	.text_3 {
		margin-left: 18rpx;
		margin-bottom: 7rpx;
		color: #ffffff;
		font-size: 32rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 38rpx;
	}

	.text_4 {
		color: #ffffff;
		font-size: 22rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 26rpx;
	}

	.text_5 {
		margin-left: 9.5rpx;
		color: #ffffff;
		font-size: 22rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 26rpx;
	}

	.text_6 {
		margin-left: 9.5rpx;
		color: #ffffff;
		font-size: 22rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 26rpx;
	}

	.text_7 {
		color: #333333;
		font-size: 32rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 38rpx;
	}

	.text_8 {
		margin-left: 8rpx;
		margin-right: 7rpx;
		color: #333333;
		font-size: 28rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 33rpx;
	}

	.text_9 {
		margin-left: 8rpx;
		margin-right: 7rpx;
		color: #333333;
		font-size: 28rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 33rpx;
	}

	.text_10 {
		margin-left: 8rpx;
		margin-right: 7rpx;
		color: #333333;
		font-size: 28rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 33rpx;
	}

	.section_3 {
		padding: 39rpx 0 34rpx;
		background-image: url($IMG_URL+'16557870748916382602.png');
		background-size: 100% 100%;
		background-repeat: no-repeat;
	}

	.section_4 {
		margin-top: 19rpx;
		padding: 22rpx 23rpx 50rpx 24rpx;
		background-color: #ffffff;
		border-radius: 16rpx;
	}

	.section_5 {
		margin-top: 20rpx;
		padding: 25rpx 22rpx 32rpx;
		border-radius: 16rpx;
		background-image: url($IMG_URL+'16557870828208089375.png');
		background-position: 0% 0%;
		background-size: 100% 100%;
		background-repeat: no-repeat;
	}

	.section_6 {
		margin-top: 20rpx;
		padding: 0 23rpx 49rpx 24rpx;
		background-color: #ffffff;
		border-radius: 16rpx;
	}

	.image_13 {
		margin-top: 8rpx;
		width: 22rpx;
		height: 22rpx;
	}

	.text_26 {
		margin-left: 12rpx;
		color: #1d6aff;
		font-size: 24rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 28rpx;
	}

	.text-wrapper_5 {
		padding: 19rpx 0 31rpx;
		flex: 1 1 326rpx;
		background-color: #ffffff;
		border-radius: 44rpx;
		height: 88rpx;
	}

	.text-wrapper_6 {
		margin-left: 34rpx;
		padding: 19rpx 0 31rpx;
		flex: 1 1 326rpx;
		background-color: #1d6aff;
		border-radius: 44rpx;
		height: 88rpx;
	}

	.group_8 {
		margin-left: 25rpx;
	}

	.group_10 {
		margin-top: 39rpx;
	}

	.image_3 {
		flex-shrink: 0;
		align-self: center;
		width: 32rpx;
		height: 32rpx;
	}

	.text_17 {
		margin-left: 10rpx;
		align-self: center;
		color: #ff371d;
		font-size: 28rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 33rpx;
	}

	.text_18 {
		margin-left: 5rpx;
		margin-right: 19rpx;
		flex: 1 1 auto;
		color: #ff371d;
		font-size: 22rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 26rpx;
		text-align: left;
	}

	.group_11 {
		padding: 30rpx 0 39rpx 5rpx;
		border-bottom: solid 1rpx #eeeeee;
	}

	.text_21 {
		margin-left: 5rpx;
		margin-top: 30rpx;
		align-self: flex-start;
		color: #333333;
		font-size: 28rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 33rpx;
	}

	.text-wrapper_4 {
		margin-top: 33rpx;
		padding: 22rpx 0;
		padding-left: 20rpx;

		background-color: #f6f7f9;
		border-radius: 16rpx;
	}

	.text-wrapper_4 uni-textarea {
		font-size: 26rpx;
	}

	.view {
		margin-top: 24rpx;
	}

	.group_17 {
		margin-top: 30rpx;
	}

	.text_27 {
		color: #333333;
		font-size: 32rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 38rpx;
	}

	.text_28 {
		color: #ffffff;
		font-size: 32rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 38rpx;
	}

	.text_11 {
		color: #333333;
		font-size: 32rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 38rpx;
	}

	.text_12 {
		color: #1d6aff;
		font-size: 24rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 28rpx;
	}

	.text_13 {
		color: #666666;
		font-size: 28rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 33rpx;
	}

	.text_14 {
		color: #333333;
		font-size: 28rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 33rpx;
	}

	.text_15 {
		color: #666666;
		font-size: 28rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 33rpx;
	}

	.text_16 {
		color: #333333;
		font-size: 28rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 33rpx;
	}

	.text_19 {
		color: #333333;
		font-size: 28rpx;
		font-family: '.AppleSystemUIFont';
		/* line-height: 40rpx; */
	}

	.text_22 {
		margin-left: 26rpx;
		color: #999999;
		font-size: 28rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 33rpx;
	}

	.group_13 {
		border-radius: 16rpx;
		position: absolute;
		left: 0;
		top: 50%;
		transform: translateY(-50%);
		width: 208rpx;
	}

	.group_14 {
		/* padding: 68rpx 0; */
		width: 208rpx;
		position: relative;
	}

	.text_23 {
		color: #333333;
		font-size: 28rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 33rpx;
	}

	.text_20 {
		color: #333333;
		font-size: 28rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 33rpx;
	}

	.image_4 {
		margin-left: 15rpx;
		margin-top: 9rpx;
		flex-shrink: 0;
		width: 14rpx;
		height: 26rpx;
	}

	.image_7 {
		width: 48rpx;
		height: 40rpx;
		position: absolute;
		left: 0;
		top: 0;
	}

	.group_15 {
		border-radius: 16rpx;
		width: 208rpx;
		top: 0;
		right: 0;
		bottom: 0;
		left: 0;
		position: absolute;
	}

	.text_24 {
		color: #333333;
		font-size: 28rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 33rpx;
	}

	.text_25 {
		margin-left: 99rpx;
		color: #999999;
		font-size: 28rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 33rpx;
	}

	.group_16 {
		width: 140rpx;
		position: absolute;
		left: 0;
		top: 0;
	}

	.image_11 {
		align-self: flex-start;
		width: 48rpx;
		height: 40rpx;
	}

	.image_12 {
		margin-top: 28rpx;
		align-self: flex-end;
	}
</style>
